package lib.bone.nepudata.domain.entity;

import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lib.bone.common.converter.JpaListLongConverter;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import lombok.Setter;
import lombok.ToString;
import org.hibernate.Hibernate;
import org.hibernate.annotations.GenericGenerator;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import javax.persistence.*;
import java.util.Date;
import java.util.List;
import java.util.Objects;

/**
 * @Author : 贾斯淇
 */

@Getter
@Setter
@ToString
@RequiredArgsConstructor
@Entity
@Table(name = "nepu_thinktank")
@EntityListeners(AuditingEntityListener.class)
@GenericGenerator(name = "jpa-uuid", strategy = "uuid")
@ApiModel("智库类成果记录")

public class NepuThinkTank {
    @Id
    @GeneratedValue(generator = "jpa-uuid")
    @ApiModelProperty(value = "智库类成果ID",name = "id")
    String id;

    @ApiModelProperty("周期ID")
    @Column(name = "cycle_id")
    String cycleId;

    /**
     * 智库类成果词典ID
     */
    @ApiModelProperty(value = "智库类成果词典ID",notes = "")
    @Column(name = "thinktank_dict_id")
    String thinktankDictId;

    /**
     * 成果名称
     */
    @ApiModelProperty(value = "成果名称",notes = "")
    @Column(name = "name")
    String name;

    /**
     * 负责人姓名
     */
    @ApiModelProperty(value = "负责人",notes = "")
    @Column(name = "leader")
    String leader;

    /**
     * 负责人ID
     */
    @ApiModelProperty(value = "负责人ID",notes = "")
    @Column(name = "leader_id")
    Long leaderId;

    /**
     * 参与成员ID列表
     */
    @ApiModelProperty(value = "参与成员ID列表",notes = "")
    @Convert(converter = JpaListLongConverter.class)
    @Column(name = "user_id_list")
    List<Long> userIdList;

    /**
     * 我校署名单位等级：一、二、三
     */
    @ApiModelProperty(value = "我校署名单位等级",notes = "")
    @Column(name = "signature_grade")
    String signatureGrade;

    /**
     * 分配所得工作量
     */
    @ApiModelProperty(value = "工作量",notes = "")
    @Column(name = "workload",scale = 2)
    Double workload;


//    @ApiModelProperty(value = "工作量",notes = "")
//    @Column(name = "workload")
//    Integer workload;
    /**
     * 审核状态
     */
//    @ApiModelProperty("审核状态")
//    @Column(name = "status")
//    Integer status;

    @CreatedDate
    @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    @ApiModelProperty(value = "记录创建时间",name = "createdTime")
    @Column(name = "created_time")
    private Date createdTime;
    @LastModifiedDate
    @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    @ApiModelProperty(value = "记录更新时间",name = "updatedTime")
    @Column(name = "updated_time")
    private Date updatedTime;

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || Hibernate.getClass(this) != Hibernate.getClass(o)) return false;
        NepuThinkTank nepuTinkTank = (NepuThinkTank) o;
        return id != null && Objects.equals(id, nepuTinkTank.id);
    }

    @Override
    public int hashCode() {
        return getClass().hashCode();
    }
}
